package org.example.search.controller;

import jakarta.annotation.Resource;
import lombok.extern.slf4j.Slf4j;
import org.example.search.entity.SearchDto;
import org.example.search.service.MilvusService;
import org.springframework.web.bind.annotation.*;

@RestController
@Slf4j
public class MilvusController {
    @Resource
    private MilvusService milvusService;

    @GetMapping("init")
    public Object init() {
        return milvusService.init();
    }

    @PostMapping("insert")
    public Object insert(@RequestBody SearchDto searchDto) throws Exception {
        return milvusService.insert(searchDto);
    }

    @PostMapping("upsert")
    public Object upsert(@RequestBody SearchDto searchDto) throws Exception {
        return milvusService.upsert(searchDto);
    }

    @GetMapping("searchVec")
    public Object searchVec(@RequestParam("title") String title) throws Exception {
        return milvusService.searchVec(title);
    }

    @PostMapping("createIndex")
    public Object createIndex() {
        return milvusService.createIndex();
    }

    @DeleteMapping("dropIndex")
    public Object dropIndex() {
        return milvusService.dropIndex();
    }
}
